home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_055 / pipedevice / misc.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  77 lines

  1.  
  2. /*
  3.  *  misc.c  - support routines - Phillip Lindsay (C) Commodore 1986
  4.  *  You may freely distribute this source and use it for Amiga Development -
  5.  *  as long as the Copyright notice is left intact.
  6.  *
  7.  * 30-SEP-86
  8.  *
  9.  *  Modified by Matthew Dillon for my PIPE: device.
  10.  */
  11.  
  12. #include <exec/types.h>
  13. #include <exec/nodes.h>
  14. #include <exec/lists.h>
  15. #include <exec/ports.h>
  16. #include <libraries/dos.h>
  17. #include <libraries/dosextens.h>
  18.  
  19. extern void returnpkt();
  20.  
  21. /* returnpkt() - packet support routine
  22.  * here is the guy who sends the packet back to the sender...
  23.  *
  24.  * (I modeled this just like the BCPL routine [so its a little redundant] )
  25.  */
  26.  
  27. void
  28. returnpktplain(packet, myproc)
  29. struct DosPacket *packet;
  30. struct Process *myproc;
  31. {
  32.     returnpkt(packet, myproc, packet->dp_Res1, packet->dp_Res2);
  33. }
  34.  
  35. void
  36. returnpkt(packet, myproc, res1, res2)
  37. struct DosPacket *packet;
  38. struct Process *myproc;
  39. ULONG  res1, res2;
  40. {
  41.     struct Message *mess;
  42.     struct MsgPort *replyport;
  43.  
  44.     packet->dp_Res1          = res1;
  45.     packet->dp_Res2          = res2;
  46.     replyport                = packet->dp_Port;
  47.     mess                     = packet->dp_Link;
  48.     packet->dp_Port          = &myproc->pr_MsgPort;
  49.     mess->mn_Node.ln_Name    = (char *) packet;
  50.     mess->mn_Node.ln_Succ    = NULL;
  51.     mess->mn_Node.ln_Pred    = NULL;
  52.     PutMsg(replyport, mess);
  53. }
  54.  
  55.  
  56. /*
  57.  * taskwait() ... Waits for a message to arrive at your port and
  58.  *   extracts the packet address which is returned to you.
  59.  */
  60.  
  61. struct DosPacket *
  62. taskwait(myproc)
  63. struct Process *myproc;
  64. {
  65.     struct MsgPort *myport;
  66.     struct Message *mymess;
  67.  
  68.     myport = &myproc->pr_MsgPort;
  69.     WaitPort(myport);
  70.     mymess = (struct Message *)GetMsg(myport);
  71.     return((struct DosPacket *)mymess->mn_Node.ln_Name);
  72. }
  73.  
  74. /* end of misc.c    */
  75.  
  76.  
  77.